<template>
	<view>
		<view class="uni-padding-wrap">
			 <view>
				 <view class="list-cell" style="overflow: hidden;padding-top: 14px;">
				 	<view class="uni-title " style="float: left;" >手机号码：</view>
				 	<view class="uni-list"> 
				 		<view class="uni-list-cell" >
				 			<input class="uni-input"  @input="changePhone" placeholder-style=" "  style="" v-model="phone" placeholder="请输入您想要查询的手机号" />
				 		</view>
				 	</view>
				 </view>
				 <view class="uni-title">选择状态:</view>
				<radio-group @change="radioChange" style="display: inline-block;">
						<view class="rad" v-for="(item, index) in items" :key="item.value">
							<radio :value="item.value" :checked="index === current" />{{item.name}}</view>
							<!-- <radio value="2" />种植户</view> -->
						<!-- <view  class="rad"><radio value="3" />批发商</view>
						<view  class="rad"><radio value="1" />经销商</view> -->
				</radio-group>
				
			</view>
			
		</view>
		<!--<view class="top" style="border-right: 1px solid #e5e5e5;">
			<p class="number">{{activityList1}}<text class="jifen">积分</text>
				<text class="my">新增积分</text> 
			</p>
		</view> 
		<view class="top">
			<p class="number">{{remaining}}<text class="jifen">积分</text>
				<text class="my">剩余积分</text> 
			</p>
		</view> -->
		<view v-if="isShow" class="main-content tui-flex tui-row" style="height: inherit;">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" :style="{height:contentHeight + 'px'}" class="scroll-Y"
			 @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
			   <!-- <view v-if="activityList==0" class="none">您还没有积分券~~~</view>	   -->
				<block v-for="item in activityList" :key="item.id">
					<view class="uni-list-cell list" v-if="item.type==0">
						<view class="uni-triplex-row"> 
							<view class="uni-triplex-left">
								<text class="uni-title uni-ellipsis title">姓名：{{item.aname}}</text>
								<text class="uni-text">存款人手机号：{{item.aphone}}</text>
								<text class="uni-text">存款金额：{{item.money}}元</text>
								<text class="uni-text">存款期限：{{item.month}}个月</text>
							</view>
							
							<view class="uni-triplex-right" >
								<view class="uni-text score"  @tap="toAgree(item.id)">通过</view> 
								<view class="uni-text score1"  @tap="toRefuse(item.id)">未通过</view> 
							</view>
							<uni-icon type="arrowright" size="18" style="line-height: 68px;"></uni-icon>
						</view>
					</view>
					<view class="uni-list-cell list" v-else>
						<view class="uni-triplex-row"> 
							<view class="uni-triplex-left">
								<text class="uni-title uni-ellipsis title">姓名：{{item.aname}}</text>
								<text class="uni-text">存款人手机号：{{item.aphone}}</text>
								<text class="uni-text">存款金额：{{item.money}}元</text>
								<text class="uni-text">存款期限：{{item.month}}个月</text>
							</view>
							
							<view class="uni-triplex-right" >
								<view class="uni-text score" v-if="item.type==1" >通过</view> 
								<view class="uni-text score1" v-if="item.type==-1">未通过</view> 
							</view>
							<uni-icon type="arrowright" size="18" style="line-height: 68px;"></uni-icon>
						</view>
					</view>
				</block>
				<prompt :isMutipleLine="false" :visible.sync="promptVisible" inputStyle="" title="充值手机号" placeholder="请输入兑换手机号" :defaultValue="title"
				  mainColor="rgb(38, 135, 218)" @confirm="clickPromptConfirm">
				  <!-- 这里放入slot内容-->
				</prompt>
			</scroll-view>
		</view> 
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone:'',
				current:0,
				promptVisible: false,
				title:uni.getStorageSync("account"),
				val0: '',
				isShow: true,
				contentHeight: 0,
				activityList: [{
					"title": '新增积分',
					"time": '2019-01-01',
					"score": '+5'
				}, {
					"title": '新增积分',
					"time": '2019-01-01',
					"score": '+5'
				}],
				items: [
					{
						value: '0',
						name: '未审核' 
					},
					{
						value: '1',
						name: '审核通过'
					},{
						value: '-1',
						name: '审核未通过'
					}],
				scrollTop: 0,
				old: {
					scrollTop: 0
				},
				activityList1: 0,
				remaining: [],
				typecode:0
			}
		},
		mounted: function() {
			this.list(0);
			let winHeight = uni.getSystemInfoSync().windowHeight;
			//创建节点选择器 获取底部导航高度 
			this.contentHeight = (winHeight - uni.upx2px(150));
			this.winHeight = winHeight;
			console.log(this.activityList1)
			// this.$store.commit('shop',{shop_id:1,shop_name:"新店铺"})
			// const value = uni.getStorageSync('id');
			// if (value) {
			// 	console.log(value);
			// }
		},
		methods: {
			changePhone(e){
				var type=this.typecode;
				this.phone=e.detail.value;
				this.list(type);
			},
			radioChange(evt) {
				var that=this;
			    this.typecode=evt.detail.value
				console.log(this.typecode)
				var typecode=this.typecode;
				that.list(typecode);
			},
			onCancel(e) {
				console.log(e)
			},
			// 页面滚动
			upper: function(e) {},
			lower: function(e) {},
			scroll: function(e) {
				this.old.scrollTop = e.detail.scrollTop
			},
			//列表
			list(typecode) {
				uni.request({
					//url:uni.getStorageSync("url")+'/kh/getKhJf',
					url: uni.getStorageSync("url") + '/yg/getCkData',
					method: 'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					data: {
						//id:7,
						page: 1,
					    type: typecode,
						limit: 9999,
						phone:this.phone
					},
					success: res => {
						this.activityList = res.data.rows;

					},
					complete: () => {
						// 请求结束执行
					}
				});
			},
			//审核通过
			toAgree(id){
				var that=this;
				uni.showModal({
				    title: '审核通过',
				    content: '是否通过该审核',
				    success: function (res) {
				        if (res.confirm) {
				            uni.request({
				            	url: uni.getStorageSync("url") + '/yg/ckSh',
				            	method: 'POST',
				            	header: {
				            		'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
				            	},
				            	data: {
				            		ckid:id,
				            		type:1,
				            	},
				            	success: res => {
				            		if(res.data.success){
				            			uni.showModal({
				            				content: res.data.msg,
				            				showCancel: false
				            			})
				            		 that.list(0);	
				            		}else{
				            			uni.showModal({
				            				content: res.data.msg,
				            				showCancel: false
				            			});
				            		}
				            	},
				            	complete: () => {
				            		// 请求结束执行
				            	}
				            });
				        } else if (res.cancel) {
				        }
				    }
				})		
			},
			//审核未通过
			toRefuse(id){
				var that=this;
				uni.showModal({
				    title: '审核未通过',
				    content: '是否不通过该审核？',
				    success: function (res) {
				        if (res.confirm) {
				            uni.request({
				            	url: uni.getStorageSync("url") + '/yg/ckSh',
				            	method: 'POST',
				            	header: {
				            		'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
				            	},
				            	data: {
				            		ckid:id,
				            		type:-1,
				            	},
				            	success: res => {
				            		if(res.data.success){
				            			uni.showModal({
				            				content: res.data.msg,
				            				showCancel: false
				            			})
				            		 that.list(0);	
				            		}else{
				            			uni.showModal({
				            				content: res.data.msg,
				            				showCancel: false
				            			});
				            		}
				            	},
				            	complete: () => {
				            		// 请求结束执行
				            	}
				            });
				        } else if (res.cancel) {
				        }
				    }
				})	
			},
			timestampToTime(timestamp) {
				var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var D = date.getDate() + ' ';
				var h = date.getHours() + ':';
				var m = date.getMinutes() + ':';
				var s = date.getSeconds();
				return Y + M + D + h + m + s;
			}
		}
	}
</script>

<style scoped>
	.score {
		background: #0a5494;
		color: #fff;
		border-radius: 1em;
		padding: 4px 13px;
		font-size: 14px;
		text-align: center;
		margin-bottom: 9px;
	}
	.score1{
		background: #878d92;
		color: #fff;
		border-radius: 1em;
		padding: 4px 13px;
		font-size: 14px;
		text-align: center;
	}
	.number {
		height: 176upx;
		margin-top: 40upx;
		text-align: center;
		font-size: 30px;
		color: #ec1515;
	}

	.jifen {
		color: #111111;
		font-size: 18px;
		display: inline-block;
		margin-left: 5px;
	}

	.my {
		display: block;
		font-size: 15px;
		color: #635a5a;
	}

	.uni-triplex-right {
		width: 16%;
		text-align: right;
		line-height: 2em;
		font-size: 20px;
	}

	.top {
		display: inline-block;
		width: 49.8%;
	}

	.list {
		border: 1px solid #128df7;
		border-radius: 60px;
		width: 86%;
		margin: 1.5em auto;
		padding: 0px 11px;
	}

	.uni-triplex-right {
		width: 22%;
		text-align: right;
		line-height: 1em;
		font-size: 20px;
		margin: auto;
	}

	.uni-triplex-left {
		width: 81%;
	}

	.title {
		font-size: 20px;
		border-bottom: 1px solid #045da9;
		width: 87%;
		color: #055da9;
	}

	.uni-list-cell:after {
		background-color: unset;
	}
	.none{
		text-align: center;
		margin-top: 25px;
		font-size: 17px;
		color: #9E9E9E;
	}
	radio-group{
		margin-top: 12upx;
	}
	.rad{
		display: inline-block;
		width: 28%;
	}
	.uni-title{
		display: inline-block;
	}
	.uni-padding-wrap{
		background: #e5e5e5;
		padding-bottom: 1em;
	}
	.uni-list {
	    /* background-color: #FFFFFF; */
	    width: 73%;
	    height: 46px;
	}
</style>
